package com.project.controller.web;

import com.project.entity.RoleResource;
import com.project.myBeans.R;
import com.project.myBeans.ResponseBean;
import com.project.service.RoleResourceService;
import com.project.service.base.BaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: TateBrown
 * @date: 2018/5/27 16:52
 * @param:
 * @return:
 */
@EnableAutoConfiguration //自动载入应用程序所需的所有Bean
@RestController //@Controller与@ResponseBody的合并
@RequestMapping(value = "/roleresource")
@Api(description = "角色资源相关",value = "roleresource")
public class RoleResourceController extends BaseService {
    @Autowired
    private RoleResourceService roleResourceService;
    /**
     * TateBrown 2018年5月27日
     *
     * @param roleResource
     * @return
     */
    @ApiOperation(" 添加单条角色资源记录")
    @PostMapping("/add")
    public R add(@RequestBody RoleResource roleResource){
        ResponseBean responseBean = new ResponseBean();
        try{
            roleResourceService.addBatch(roleResource);
            return R.ok("操作成功");
        }catch(Exception e){
            e.printStackTrace();
            return R.error("操作失败");
        }
    }
}
